//
//  JSBaseViewController.m
//  JSBaseProject
//
//  Created by Apple on 2017/10/29.
//  Copyright © 2017年 Apple. All rights reserved.
//

#import "JSBaseViewController.h"

@interface JSBaseViewController ()

@end

@implementation JSBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.dataService = [[JSBaseDataService alloc] init];
    self.dataService.delegate = self;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)didInitialized{
    [super didInitialized];
//    self.view.js_RandomColor();
}
//设置当前导航栏是否需要使用自定义的 push 时候 transition 效果，默认返回NO，须足这里配置设置YES。
- (BOOL)shouldCustomNavigationBarTransitionWhenPushAppearing {
    return YES;
}
//设置当前导航栏是否需要使用自定义的 pop  时候 transition 效果，默认返回NO，须足这里配置设置YES。
- (BOOL)shouldCustomNavigationBarTransitionWhenPopAppearing {
    return YES;
}

#pragma mark -------JSDataServiceDelegate-----------------
// 请求数据回调
-(void)dataServiceDidUpdate:(JSBaseDataService *)service data:(id)data error:(NSError *)error{
    NSLog(@"data:%@ -- error:%@", data,error);
}
-(NSString *)dataServiceUrlSting{
    // 请求所需url
    return BASE_URL;
}
-(NSMutableDictionary *)dataServiceParameter{
    // 请求所需参数
    return @{}.mutableCopy;
}
-(NSInteger)dataServicePageNumber{
    return 0;
}
- (void)showMessage:(NSString *)msg {
    CGFloat padding = 10;
    
    YYLabel *label = [YYLabel new];
    label.text = msg;
    label.font = [UIFont systemFontOfSize:16];
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor whiteColor];
    label.backgroundColor = [UIColor colorWithRed:0.033 green:0.685 blue:0.978 alpha:0.730];
    label.width = self.view.width;
    label.textContainerInset = UIEdgeInsetsMake(padding, padding, padding, padding);
    label.height = [msg heightForFont:label.font width:label.width] + 2 * padding;
    
    label.bottom = (kiOS7Later ? 64 : 0);
    [self.view addSubview:label];
    [UIView animateWithDuration:0.3 animations:^{
        label.top = (kiOS7Later ? 64 : 0);
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.2 delay:2 options:UIViewAnimationOptionCurveEaseInOut animations:^{
            label.bottom = (kiOS7Later ? 64 : 0);
        } completion:^(BOOL finished) {
            [label removeFromSuperview];
        }];
    }];
}
@end
